<template>
	<div>
		<el-tabs v-model="activeName" @tab-click="handleTabChange">
			<el-tab-pane v-for="(item, index) in tabsList" :key="index" :label="item.label" :name="item.value"> </el-tab-pane>

			<div class="content-card">
				<html-label :title="activeLabelTitle">
				</html-label>

				<component
					class="pd10"
          v-if="!loading"
					:is="whickComm[activeName]"
					@refresh="handleRefresh"
					:nowRowData="nowRowData"
					:actionBtn="false"
					:searchConfig="false"
          :soleKey="`dpFoundationPractitioners-${nowRowData.idCard}`"
				>
				</component>
			</div>
		</el-tabs>
	</div>
</template>

<script setup lang="ts">
import BaseDetail from './BaseDetail/index.vue'
import Extend from './Extend/index.vue'
import apiMod from '@/apiMod'
import { useCommonStore } from '@/stores/common'

const { setLoading } = useCommonStore()

const whickComm = {
	BaseDetail,
	Extend,
}
type Props = {
	nowRowData?: any
	showBtn?: boolean
}
const props = withDefaults(defineProps<Props>(), {
	showBtn: true,
})

const baseData = ref({})
provide('nowRowData', baseData)

const emit = defineEmits(['refresh', 'rechange'])
const activeLabelTitle = ref('基础信息')
const loading = ref(false)
const tabsList: any = [
	{ label: '基础信息', value: 'BaseDetail' },
	{ label: '扩展信息', value: 'Extend' },
]
const activeName = ref('BaseDetail')

const getInitData = () => {
  loading.value = true 
  setLoading(true)
	apiMod.view_dpFoundationPractitionersFile_all({idCard: props.nowRowData.idCard,}).then((res) => {
    const data = res.data ||{}
    baseData.value = data
    loading.value = false
    setLoading(false)
	})
}

const handleTabChange = (tab) => {
	activeLabelTitle.value = tab.props.label
}

const handleRefresh = () => {
	emit('refresh')
}

onMounted(()=> {
  getInitData()
})
</script>

<style scoped></style>
